///  <copyright file="MallowMain.cs" company="Infozoom" author="Stefan Zschocke">
///    You must not remove this notice, or any other, from this software.
///    Otherwise do with it whatever you want.
///    infoZoom may not be made liable for any damages whatsoever 
///    (including, without limitation, damages for loss of business profits, 
///    business interruption, loss of business information or other pecuniary loss)
///    arising out of use of or inability to use the Software
/// </copyright>
using System.Xml;

namespace Mallow
{
    /// <summary>
    /// Summary description for Component.
    /// </summary>
    internal class File
    {
        string mFileName;
        XmlNode mNode;
        Component mParent;
        Mallow mMallow;
        bool mFound;
        bool mNew;

        internal File(Mallow mallow, Component parent, XmlNode node, bool isNew)
        {
            mMallow = mallow;
            mParent = parent;
            mNode = node;
            mFound = isNew;
            mNew = isNew;
        }

        internal XmlNode Node { get { return mNode; } }
        internal bool Found { get { return mFound; } set { mFound = value; } }
        internal bool IsNew { get { return mNew; } set { mNew = value; } }
        internal Component Component { get { return mParent; } }

        internal string FileName
        {
            get
            {
                if (mFileName == null)
                {
                    XmlAttribute a = mNode.Attributes["LongName"];
                    if (a == null) a = mNode.Attributes["Name"];
                    mFileName = a.Value;
                }
                return mFileName;
            }
        }

        internal string GetFullRelativePath()
        {
            string s = Component.Directory.GetFullRelativeDirectoryName();
            if (s.Length > 0) s += "\\";
            s += FileName;
            return s;
        }
    }
}
